let { z } = require('zod')

const enumSchema = z.enum(['red', 'yellow', 'blue'])

try {
  const result1 = enumSchema.parse('red')
  console.log('result1 ', result1) // result1  red

  const result2 = enumSchema.parse('pink')
  console.log('result2 ', result2) // 报错
} catch(e) {
  console.log(e.errors)

  // [
  //   {
  //     received: 'pink',
  //     code: 'invalid_enum_value',
  //     options: [ 'red', 'yellow', 'blue' ],
  //     path: [],
  //     message: "Invalid enum value. Expected 'red' | 'yellow' | 'blue', received 'pink'"
  //   }
  // ]
}

